#include <../boost/bits/stdc++.h>
using namespace std;
const int L = 2022, R = 2022222022;
const int LL = 22, RR = 19999;//偶数位，完全对称
const int LLL = 111, RRR = 99999;//奇数位，
bool check(int x) {
    int t = -1;
    while (x) {
        if (t != -1 && t < x % 10) return false;
        t = x % 10;
        x /= 10;
    }
    return true;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int ans = 0;
    for (int i = LL; i <= RR; ++i) {
        if (check(i)) ++ans;
    }
    for (int i = LLL; i <= RRR; ++i) {
        if (check(i)) ++ans;
    }
    cout << ans;
    return 0;
}